package com.niiwoo.civet.trade.configuration;
import com.niiwoo.asset.org.business.constants.OrgRabbitConstant;
import com.niiwoo.civet.account.constant.MQConstant;
import com.niiwoo.civet.trade.constant.MqConstant;
import com.niiwoo.civet.trade.constant.TradeMqConstant;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by fushengcai on 2017/11/3.
 */
@Configuration
public class RabbitConfiguration {

    @Bean
    public Exchange autoRefundWithholdExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.AUTO_REFUND_WITHHOLD_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }

    @Bean
    public Queue autoRefundWithholdQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.AUTO_REFUND_WITHHOLD_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }

    @Bean
    public Binding doBindingRefundWithhold(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(autoRefundWithholdQueue(admin)).to(autoRefundWithholdExchange(admin)).with(MqConstant.AUTO_REFUND_WITHHOLD).noargs();
        admin.declareBinding(binding);
        return binding;
    }


    /**
     * 00：15 自动还款
     * @param admin
     * @return
     */
    @Bean
    public Exchange autoRefundGuaranteeExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.AUTO_REFUND_GUARANTEE_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue autoRefundGuaranteeQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.AUTO_REFUND_GUARANTEE_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding dogBindingRefundGuarantee(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(autoRefundGuaranteeQueue(admin)).to(autoRefundGuaranteeExchange(admin)).with(MqConstant.AUTO_REFUND_GUARANTEE_ROUTE).noargs();
        admin.declareBinding(binding);
        return binding;
    }



    /**
     * 担保公司垫付
     * @param admin
     * @return
     */
    @Bean
    public Exchange autoGuaranteeExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.AUTO_GUARANTEE_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue autoGuaranteeQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.AUTO_GUARANTEE_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding dogBindingGuarantee(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(autoGuaranteeQueue(admin)).to(autoGuaranteeExchange(admin)).with(MqConstant.AUTO_GUARANTEE_ROUTE).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /**
     * 罚息更新
     *
     * @param admin
     * @return
     */
    @Bean
    public Exchange autoPenaltyUpdateExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(TradeMqConstant.AUTO_PENALTY_UPDATE_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }

    @Bean
    public Queue autoPenaltyUpdateQueue(RabbitAdmin admin) {
        Queue queue = new Queue(TradeMqConstant.AUTO_PENALTY_UPDATE_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }

    @Bean
    public Binding dogBindingAutoPenaltyUpdate(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(autoPenaltyUpdateQueue(admin)).to(autoPenaltyUpdateExchange(admin)).with(TradeMqConstant.AUTO_PENALTY_UPDATE_ROUTE).noargs();
        admin.declareBinding(binding);
        return binding;
    }




	@Bean
	public Exchange projectLendAbnormityExchange(RabbitAdmin admin) {
		Exchange exchange = new DirectExchange(MqConstant.PROJECT_LEND_ABNORMITY_EXCHANGE, true, true);
		admin.declareExchange(exchange);
		return exchange;
	}

	@Bean
	public Queue projectLendAbnormityQueue(RabbitAdmin admin) {
		Queue queue = new Queue(MqConstant.PROJECT_LEND_ABNORMITY_QUEUE, true);
		admin.declareQueue(queue);
		return queue;
	}

	@Bean
	public Binding doBindingProjectLendAbnormity(RabbitAdmin admin) {
		Binding binding = BindingBuilder.bind(projectLendAbnormityQueue(admin)).to(projectLendAbnormityExchange(admin))
				.with(MqConstant.PROJECT_LEND_ABNORMITY).noargs();
		admin.declareBinding(binding);
		return binding;
	}


    @Bean
    public Exchange fadadaContractExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.FADADA_CONTRACT_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }

    @Bean
    public Queue fadadaWithholdContractQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.FADADA_WITHHOLD_CONTRACT_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }

    @Bean
    public Binding dogBindingFadadaWithhold(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(fadadaWithholdContractQueue(admin)).to(fadadaContractExchange(admin)).with(MqConstant.FADADA_WITHHOLD_CONTRACT_ROUTE).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    @Bean
	public Exchange projectLendContractExchange(RabbitAdmin admin) {
		Exchange exchange = new DirectExchange(MqConstant.PROJECT_LEND_CONTRACT_EXCHANGE, true, true);
		admin.declareExchange(exchange);
		return exchange;
	}

	@Bean
	public Queue projectLendContractQueue(RabbitAdmin admin) {
		Queue queue = new Queue(MqConstant.PROJECT_LEND_CONTRACT_QUEUE, true);
		admin.declareQueue(queue);
		return queue;
	}

	@Bean
	public Binding doBindingProjectLendContract(RabbitAdmin admin) {
		Binding binding = BindingBuilder.bind(projectLendContractQueue(admin)).to(projectLendContractExchange(admin))
				.with(MqConstant.PROJECT_LEND_CONTRACT).noargs();
		admin.declareBinding(binding);
		return binding;
	}

    @Bean
    public Exchange blackListStorageExchange() {
        return new DirectExchange(MqConstant.BLACK_LIST_STORAGE_EXCHANGE, true, true);
    }

    @Bean
    public Queue blackListStorageQueue() {
        return new Queue(MqConstant.BLACK_LIST_STORAGE_QUEUE, true);
    }

    @Bean
    public Binding doBindingBlackListStorage() {
        return BindingBuilder.bind(blackListStorageQueue()).to(blackListStorageExchange())
                .with(MqConstant.BLACK_LIST_STORAGE_ROUTE).noargs();
    }

    /*-------------------- 流标相关 start --------------------*/
    @Bean
    public Exchange createProjectSnapshotExchange() {
        return new DirectExchange(MqConstant.CREATE_PROJECT_SNAPSHOT_EXCHANGE, true, true);
    }

    @Bean
    public Queue createProjectSnapshotQueue() {
        return new Queue(MqConstant.CREATE_PROJECT_SNAPSHOT_QUEUE, true);
    }

    @Bean
    public Binding createProjectSnapshotBinding() {
        return BindingBuilder.bind(createProjectSnapshotQueue()).to(createProjectSnapshotExchange()).with(MqConstant.CREATE_PROJECT_SNAPSHOT_ROUTE).noargs();
    }

    @Bean
    public Exchange auditWorkTaskExchange() {
        return new DirectExchange(MqConstant.AUDIT_WORK_TASK_EXCHANGE, true, true);
    }

    @Bean
    public Queue auditWorkTaskQueue() {
        return new Queue(MqConstant.AUDIT_WORK_TASK_CANCEL_QUEUE, true);
    }

    @Bean
    public Binding auditWorkTaskBinding() {
        return BindingBuilder.bind(auditWorkTaskQueue()).to(auditWorkTaskExchange()).with(MqConstant.AUDIT_WORK_TASK_CANCEL_ROUTE).noargs();
    }
    /*-------------------- 流标相关 end --------------------*/

//    @Bean
//    public Exchange blackListStorageExchange(RabbitAdmin admin) {
//        Exchange exchange = new DirectExchange(MqConstant.BLACK_LIST_STORAGE_EXCHANGE, true, true);
//        admin.declareExchange(exchange);
//        return exchange;
//    }
//
//    @Bean
//    public Queue blackListStorageQueue(RabbitAdmin admin) {
//        Queue queue = new Queue(MqConstant.BLACK_LIST_STORAGE_QUEUE, true);
//        admin.declareQueue(queue);
//        return queue;
//    }
//
//    @Bean
//    public Binding doBindingBlackListStorage(RabbitAdmin admin) {
//        Binding binding = BindingBuilder.bind(blackListStorageQueue(admin)).to(blackListStorageExchange(admin))
//                .with(MqConstant.BLACK_LIST_STORAGE_ROUTE).noargs();
//        admin.declareBinding(binding);
//        return binding;
//    }




     /*-------------------- 还款优化相关 开始 --------------------*/
     @Bean
     public Exchange refundnewExchange(RabbitAdmin admin) {
         Exchange exchange = new DirectExchange(MqConstant.REFUNDNEW_EXCHANGE, true, true);
         admin.declareExchange(exchange);
         return exchange;
     }

    @Bean
    public Queue refundnewFullQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.REFUNDNEW_FULL_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding doBindingRefundnewFull(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(refundnewFullQueue(admin)).to(refundnewExchange(admin)).with(MqConstant.REFUNDNEW_FULL_ROUTE).noargs();
        admin.declareBinding(binding);
        return binding;
    }


    @Bean
    public Queue refundnewPartialQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.REFUNDNEW_PARTIAL_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding doBindingRefundnewPartial(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(refundnewPartialQueue(admin)).to(refundnewExchange(admin)).with(MqConstant.REFUNDNEW_PARTIAL_ROUTE).noargs();
        admin.declareBinding(binding);
        return binding;
    }


    @Bean
    public Queue refundnewCompensatoryQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.REFUNDNEW_COMPENSATORY_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding doBindingRefundnewCompensatory(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(refundnewCompensatoryQueue(admin)).to(refundnewExchange(admin)).with(MqConstant.REFUNDNEW_COMPENSATORY_ROUTE).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    @Bean
    public Queue refundnewCompensatorySpecifyQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.REFUNDNEW_COMPENSATORY_SPECIFY_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding doBindingRefundnewCompensatorySpecify(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(refundnewCompensatorySpecifyQueue(admin)).to(refundnewExchange(admin)).with(MqConstant.REFUNDNEW_COMPENSATORY_SPECIFY_ROUTE).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    @Bean
    public Queue refundnewWithholdQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.REFUNDNEW_WITHHOLD_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding doBindingRefundnewWithhold(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(refundnewWithholdQueue(admin)).to(refundnewExchange(admin)).with(MqConstant.REFUNDNEW_WITHHOLD_ROUTE).noargs();
        admin.declareBinding(binding);
        return binding;
    }



    /*************代扣*****************/
    @Bean
    public Exchange withholdApplyExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.WITHHOLD_APPLY_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }

    @Bean
    public Queue withholdApplyDataQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.WITHHOLD_APPLY_DATA_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding doBindingWithholdApplyData(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(withholdApplyDataQueue(admin)).to(withholdApplyExchange(admin)).with(MqConstant.WITHHOLD_APPLY_DATA_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    @Bean
    public Queue withholdApplyDataResultQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.WITHHOLD_APPLY_DATAREULST_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding doBindingWithholdApplyDataResult(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(withholdApplyDataResultQueue(admin)).to(withholdApplyExchange(admin)).with(MqConstant.WITHHOLD_APPLY_DATAREULST_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    @Bean
    public Queue withholdOverdue50DayQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.WITHHOLD_OVERDUE_50_DAY_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding withholdOverdue50DayRouting(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(withholdOverdue50DayQueue(admin)).to(withholdApplyExchange(admin)).with(MqConstant.WITHHOLD_OVERDUE_50_DAY_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    @Bean
    public Queue withholdOverdue50DaySuccessQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.WITHHOLD_OVERDUE_50_DAY_SUCCESS_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding withholdOverdue50DaySuccessRouting(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(withholdOverdue50DaySuccessQueue(admin)).to(withholdApplyExchange(admin)).with(MqConstant.WITHHOLD_OVERDUE_50_DAY_SUCCESS_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }


    /*************还款/垫付发起冻结*****************/
    @Bean
    public Exchange refundFreezeExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.REFUND_FREEZE_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue refundFreezeQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.REFUND_FREEZE_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding refundFreezeBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(refundFreezeQueue(admin)).to(refundFreezeExchange(admin)).with(MqConstant.REFUND_FREEZE_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /*************还款/垫付冻结结果*****************/
    @Bean
    public Exchange refundFreezeResultExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.REFUND_FREEZE_RESULT_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue refundFreezeResultQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.REFUND_FREEZE_RESULT_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }

    @Bean
    public Binding refundFreezeResultBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(refundFreezeResultQueue(admin)).to(refundFreezeResultExchange(admin)).with(MqConstant.REFUND_FREEZE_RESULT_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /*************还款/垫付解冻结果*****************/
    @Bean
    public Exchange refundUnfreezeExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.REFUND_UNFREEZE_RESULT_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue refundUnfreezeQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.REFUND_UNFREEZE_RESULT_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding refundUnfreezeBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(refundUnfreezeQueue(admin)).to(refundUnfreezeExchange(admin)).with(MqConstant.REFUND_UNFREEZE_RESULT_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /*************还款债权校验MQ*****************/
    @Bean
    public Exchange refundValidateExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MQConstant.REFUND_VALIDATE_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue refundValidateQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MQConstant.REFUND_VALIDATE_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding refundValidateBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(refundValidateQueue(admin)).to(refundValidateExchange(admin)).with(MQConstant.REFUND_VALIDATE_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }



    @Bean
    public Exchange orgCommonDirectExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(OrgRabbitConstant.Exchange.ORG_COMMON_DIRECT_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue pushProjectSuccessNotifyQueue(RabbitAdmin admin) {
        Queue queue = new Queue(OrgRabbitConstant.Queue.PUSH_PROJECT_SUCCESS_NOTIFY_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding pushProjectSuccessNotifyQueueBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(pushProjectSuccessNotifyQueue(admin)).to(orgCommonDirectExchange(admin)).with(
                OrgRabbitConstant.getRoutingKey(OrgRabbitConstant.Exchange.ORG_COMMON_DIRECT_EXCHANGE, OrgRabbitConstant.Queue.PUSH_PROJECT_SUCCESS_NOTIFY_QUEUE)).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /*************还款订单明细处理成功*****************/
    @Bean
    public Exchange refundOrderDetailExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(TradeMqConstant.REFUND_ORDER_DETAIL_HANLDER_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue refundOrderDetailQueue(RabbitAdmin admin) {
        Queue queue = new Queue(TradeMqConstant.REFUND_ORDER_DETAIL_HANLDER_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding refundOrderDetailBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(refundOrderDetailQueue(admin)).to(refundOrderDetailExchange(admin)).with(TradeMqConstant.REFUND_ORDER_DETAIL_HANLDER_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }
    
    /*************还款订单明细处理成功*****************/
    @Bean
    public Exchange refundNotifyHandleExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(TradeMqConstant.REFUND_NOTIFY_HANDLE_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue refundNotifyHandleQueue(RabbitAdmin admin) {
        Queue queue = new Queue(TradeMqConstant.REFUND_NOTIFY_HANDLE_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding refundNotifyHandleBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(refundNotifyHandleQueue(admin)).to(refundNotifyHandleExchange(admin)).with(TradeMqConstant.REFUND_NOTIFY_HANDLE_ROUTINGKEY).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    @Bean
    public Exchange creditorTransferProtocolSignExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.CREDITOR_TRANSFER_PROTOCOL_SIGN_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }

    @Bean
    public Queue creditorTransferProtocolSignQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.CREDITOR_TRANSFER_PROTOCOL_SIGN_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }

    @Bean
    public Binding creditorTransferProtocolSignContract(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(creditorTransferProtocolSignQueue(admin)).to(creditorTransferProtocolSignExchange(admin))
                .with(MqConstant.CREDITOR_TRANSFER_PROTOCOL_SIGN_CONTRACT).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /************* 标的待发布 *****************/
    @Bean
    public Exchange projectWaitPublishExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.PROJECT_WAIT_PUBLISH_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue projectWaitPublishQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.PROJECT_WAIT_PUBLISH_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding projectWaitPublishBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(projectWaitPublishQueue(admin)).to(projectWaitPublishExchange(admin)).with(MqConstant.PROJECT_WAIT_PUBLISH_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /************* 标的待发布转发布 *****************/
    @Bean
    public Exchange projectWaitPublishToPublishExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.PROJECT_WAIT_PUBLISH_TO_PUBLISH_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue projectWaitPublishToPublishQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.PROJECT_WAIT_PUBLISH_TO_PUBLISH_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding projectWaitPublishToPublishBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(projectWaitPublishToPublishQueue(admin)).to(projectWaitPublishToPublishExchange(admin)).with(MqConstant.PROJECT_WAIT_PUBLISH_TO_PUBLISH_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /************* 上标 *****************/
    @Bean
    public Exchange projectPublishExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.PROJECT_PUBLISH_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue projectPublishQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.PROJECT_PUBLISH_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding projectPublishBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(projectPublishQueue(admin)).to(projectPublishExchange(admin)).with(MqConstant.PROJECT_PUBLISH_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /************* 分端配置修改 *****************/
    @Bean
    public Exchange allotChannelModifyExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.ALLOT_CHANNEL_CONFIG_MODIFY_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue allotChannelModifyQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.ALLOT_CHANNEL_CONFIG_MODIFY_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding allotChannelModifyBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(allotChannelModifyQueue(admin)).to(allotChannelModifyExchange(admin)).with(MqConstant.ALLOT_CHANNEL_CONFIG_MODIFY_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /************* 分端发标 *****************/
    @Bean
    public Exchange allotChannelExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.ALLOT_CHANNEL_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue allotChannelQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.ALLOT_CHANNEL_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding allotChannelBinding(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(allotChannelQueue(admin)).to(allotChannelExchange(admin)).with(MqConstant.ALLOT_CHANNEL_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /************* 标的包打包 *****************/
    @Bean
    public Exchange projectPackagePackagingExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.PROJECT_PACKAGE_PACKAGING_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue projectPackagePackagingQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.PROJECT_PACKAGE_PACKAGING_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding projectPackagePackagingRouting(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(projectPackagePackagingQueue(admin)).to(projectPackagePackagingExchange(admin)).with(MqConstant.PROJECT_PACKAGE_PACKAGING_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /************* 标的包加标 *****************/
    @Bean
    public Exchange projectPackageAddProjectExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.PROJECT_PACKAGE_ADD_PROJECT_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue projectPackageAddProjectQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.PROJECT_PACKAGE_ADD_PROJECT_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding projectPackageAddProjectRouting(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(projectPackageAddProjectQueue(admin)).to(projectPackageAddProjectExchange(admin)).with(MqConstant.PROJECT_PACKAGE_ADD_PROJECT_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /************* 标的包发布 *****************/
    @Bean
    public Exchange projectPackagePublishingExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.PROJECT_PACKAGE_PUBLISHING_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue projectPackagePublishingQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.PROJECT_PACKAGE_PUBLISHING_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding projectPackagePublishingRouting(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(projectPackagePublishingQueue(admin)).to(projectPackagePublishingExchange(admin)).with(MqConstant.PROJECT_PACKAGE_PUBLISHING_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }

    /************* 标的包发布(满标) *****************/
    @Bean
    public Exchange projectPackagePublishingForFullExchange(RabbitAdmin admin) {
        Exchange exchange = new DirectExchange(MqConstant.PROJECT_PACKAGE_PUBLISHING_FOR_FULL_EXCHANGE, true, true);
        admin.declareExchange(exchange);
        return exchange;
    }
    @Bean
    public Queue projectPackagePublishingForFullQueue(RabbitAdmin admin) {
        Queue queue = new Queue(MqConstant.PROJECT_PACKAGE_PUBLISHING_FOR_FULL_QUEUE, true);
        admin.declareQueue(queue);
        return queue;
    }
    @Bean
    public Binding projectPackagePublishingForFullRouting(RabbitAdmin admin) {
        Binding binding = BindingBuilder.bind(projectPackagePublishingForFullQueue(admin)).to(projectPackagePublishingForFullExchange(admin)).with(MqConstant.PROJECT_PACKAGE_PUBLISHING_FOR_FULL_ROUTING).noargs();
        admin.declareBinding(binding);
        return binding;
    }
}
